package com.rd.student.ruanjian.class4.zhouzihe.exam;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;

public class Test {
    public static void main(String[] args) throws IOException {
        ArrayList<Student> arrayList = new ArrayList<>();
        for (int i = 0; i < 3; i++) {
            Scanner scanner = new Scanner(System.in);
            System.out.println("请输入学生姓名");
            String name = scanner.next();
            System.out.println("请输入语文成绩");
            int scoreChinese = scanner.nextInt();
            System.out.println("请输入数学成绩");
            int scoreMath = scanner.nextInt();

        }
        Student s1 = new Student("李四", 99, 88, 187);
        Student s2 = new Student("张三", 20, 90, 110);
        Student s3 = new Student("王五", 100, 100, 200);
        arrayList.add(s1);
        arrayList.add(s2);
        arrayList.add(s3);
        String projectPath = System.getProperty("user.dir");
        File f1 = new File(projectPath + "\\" + "Student.txt");
        f1.createNewFile();
        BufferedWriter bw = new BufferedWriter(new FileWriter(f1));
        bw.write("学生姓名\t");
        bw.write("语文成绩\t");
        bw.write("数学成绩\t");
        bw.write("总分\t");
        bw.newLine();
        bw.flush();
        for (Student s : arrayList) {
            String name = s.getName();
            int chinese = s.getScoreChinese();
            int math = s.getScoreMath();
            int total = s.getScoreSum();

            bw.write(name + "\t");
            bw.write(chinese + "\t");
            bw.write(math + "\t");
            bw.write(total + "\t");
            bw.newLine();
            bw.flush();
        }
        bw.close();
    }
}


class Student {
    String name;
    int scoreMath;
    int scoreChinese;
    int scoreSum;

    public Student(String name, int scoreMath, int scoreChinese, int scoreSum) {
        this.name = name;
        this.scoreMath = scoreMath;
        this.scoreChinese = scoreChinese;
        this.scoreSum = scoreSum;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getScoreMath() {
        return scoreMath;
    }

    public void setScoreMath(int scoreMath) {
        this.scoreMath = scoreMath;
    }

    public int getScoreChinese() {
        return scoreChinese;
    }

    public void setScoreChinese(int scoreChinese) {
        this.scoreChinese = scoreChinese;
    }

    public int getScoreSum() {
        return scoreSum;
    }

    public void setScoreSum(int scoreSum) {
        this.scoreSum = scoreSum;
    }
}
